package com.bookmall.cart.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bookmall.cart.domain.OrderInfoItem;
import com.bookmall.cart.mapper.OrderInfoItemMapper;
import com.bookmall.cart.service.IOrderInfoItemService;
import com.bookmall.common.utils.MyQuery;
import com.bookmall.common.utils.PageUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description:
 * @Author 胡菜鸡
 * @Create 2022-04-21-11:11
 */
@Service
public class OrderInfoItemServiceImpl extends ServiceImpl<OrderInfoItemMapper, OrderInfoItem> implements IOrderInfoItemService {
    /**
     * 根据订单号查询该订单的所有订单项
     * @author 胡菜鸡
     * @date 2022/4/27 15:56
     */
    @Override
    public List<OrderInfoItem> getOrderItems(String orderSn) {
        LambdaQueryWrapper<OrderInfoItem> wrapper = new LambdaQueryWrapper<>();
        return list(wrapper.eq(OrderInfoItem::getOrderSn, orderSn));
    }

    /**
     * 分页查询所有订单项
     * @author 胡菜鸡
     * @date 2022/5/7 17:42
     */
    @Override
    public PageUtils getOrderItemsPageList(OrderInfoItem orderInfoItem) {
        IPage<OrderInfoItem> page = page(new MyQuery<OrderInfoItem>().getPage(orderInfoItem), new QueryWrapper<>(orderInfoItem));
        return new PageUtils(page);
    }
}
